<?php
//your function
//php调用webseriver
//Decrypt解密   Encrypt加密
function soap_client($type='Decrypt',$str)
{
	require_once './include/nusoap.php';
	$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
	$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
	$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
	$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
	$Text = isset($str) ? $str : '';
	$WTOTD_URL = WTOTD_URL;
	$client = new soapclient($WTOTD_URL.'webInterface/EncryptionService.asmx?WSDL', true,
							$proxyhost, $proxyport, $proxyusername, $proxypassword);
	$client->soap_defencoding = 'UTF-8';
	$client->decode_utf8 = false;						
	$err = $client->getError();
	if ($err) {
		echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
	}
	//echo $WTOTD_URL;
	$params2 = array('op'=>$type, 'Text'=>$Text);
	$result = $client->call($type, $params2, '', '', false, true);
	//print_r($result);
	return $result[$type.'Result'];
}

//获取随机验证码
	function get_randp($user1)
	{
		global $db;
		//不用加密
		$data = $db->get_one("select RandP from member where username='{$user1}' limit 1");
		return is_array($data) ? $data['RandP'] : 0;
	}
	//自动注册账户
	function autoreg($member=array())
	{	
		global $db;
		$member['addtime'] = $member['logintime'] = time();
		$id = $db->insert('member', $member);
		return $id;
	}
	//检查用户是否存在
	function userinfo($user1)
	{
		global $db;
		//不用加密
		$data = $db->get_one("select username from member where username='{$user1}' limit 1");
		return is_array($data) ? 1 : 0;
	}
	//跳转页面
	function dheader($url)
	{
	exit(header('location:'.$url));
	}
	//购买地址
	function get_buy($v=array())
	{
				$PSendTime = $BMoney = $DMoney = $JeiTime = $PayType = $BuyID = $salerID = $LogisticsDate = 1;

			extract($v);
			$array = array(
			'IDD'=>array('name'=>'id','urlencode'=>0),//供应id
			'PTypeName'=>array('PTypeName'=>'_catname','urlencode'=>1),//供应产品分类名称
			'Pname'=>array('name'=>'Pname','urlencode'=>1),//供应产品名称
			/**/'Pmodel'=>array('name'=>'Pmodel','urlencode'=>1),//供应型号
			'PStandard'=>array('name'=>'PStandard','urlencode'=>1),//供应规格
			'PBrand'=>array('name'=>'PBrand','urlencode'=>1),//产品品牌
			//'Pintroduce'=>array('name'=>'content','urlencode'=>1),//介绍
			'PBType'=>array('name'=>'PBType','urlencode'=>1),//标准类型
			'PLimit'=>array('name'=>'PLimit','urlencode'=>1),// 产品等级
			'PBiao'=>array('name'=>'PBiao','urlencode'=>1),//表面
			'PStuff'=>array('name'=>'PStuff','urlencode'=>1),//材料
			'PUnut'=>array('name'=>'PUnut','urlencode'=>1),//计量单位
			'PPrice'=>array('name'=>'PPrice','urlencode'=>0),//价格
			'PCount'=>array('name'=>'PCount','urlencode'=>0),//最小起订量
			'PAllCount'=>array('name'=>'PAllCount','urlencode'=>0),//总量
			'UserName'=>array('name'=>'UserName','urlencode'=>1),//总量
			'PSendTime'=>array('name'=>'PSendTime','urlencode'=>0),//发货期限
			'Lname'=>array('name'=>'Lname','urlencode'=>1),//联系人
			'Phone'=>array('name'=>'Phone','urlencode'=>0),//手机
			'Tel'=>array('name'=>'Tel','urlencode'=>0),//电话 
			'Fax'=>array('name'=>'Fax','urlencode'=>0),//传真
			'Address'=>array('name'=>'Address','urlencode'=>1),//地址
			'Email'=>array('name'=>'Email','urlencode'=>0),//邮箱
			'Msn'=>array('name'=>'Msn','urlencode'=>0),//msn
			'QQ'=>array('name'=>'QQ','urlencode'=>0),//qq
			'Alww'=>array('name'=>'Alww','urlencode'=>0),//ali
			'Skype'=>array('name'=>'Skype','urlencode'=>0),//msn
			'PayType'=>array('name'=>'PayType','urlencode'=>0),//支付方式
			'BMoney'=>array('name'=>'BMoney','urlencode'=>0),//保证金
			'DMoney'=>array('name'=>'DMoney','urlencode'=>0),//定金
			'JeiTime'=>array('name'=>'JeiTime','urlencode'=>0),//结款时间
			'BuyID'=>array('name'=>'BuyID','urlencode'=>0),//BuyID
			'salerID'=>array('name'=>'salerID','urlencode'=>0),//结款时间
			'LogisticsDate'=>array('name'=>'LogisticsDate','urlencode'=>0),//流周期地
			'LogisticsID'=>array('name'=>'LogisticsID','urlencode'=>0),//物流方式 1=>'平台物流（买家包）',2=>'平台物流（卖家包）',3=>'买家自带物流',4=>'卖家自带物流'
			'RealBuyNum'=>array('name'=>'PCount','urlencode'=>0),//实际购买数量
			'ProAddress'=>array('name'=>'ProAddress','urlencode'=>1),//存放地
			'LongDate'=>array('name'=>'LongDate','urlencode'=>1),//最长合约天数
				 /// <summary>
			/// 物流费用
			/// </summary>
			//public decimal LogisticsMoney { set; get; }
			/// <summary>
			/// 物流联系人
			/// </summary>
		   // public string LogisticsLianxiName { set; get; }
			/// <summary>
			/// 车牌号组
			/// </summary>
			//public string TruckIDs { set; get; }
			/// <summary>
			/// 公司允许超限天数
			/// </summary>
		   // public int CompanyAddDate { set; get; }
			
			
		);
		$urlpars = WTOTD_URL.'ShopCar.aspx?returnUrl='.HTTP_REFERER;
		foreach($array as $k=>$v)
		{
			$v1 = ($v['urlencode']==1) ? urlencode($$v['name']) : $$v['name'];
			//$v1 = $$v['name'];
			$urlpars .= '&'.$k.'='.$v1;
		}
		//echo $username;
		return $urlpars;
	}